<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/22 14:27
 * Note:
 */
namespace Admin\Model;
use Think\Model;

class AuthModel extends Model
{
    public function getAuth($group_id = 0){
        if (!$group_id) return false;
        return $this->select();
    }

    public function getInfoByName($name = ''){
        if (!$name) return false;
        return $this->where(array('auth'=>$name))->find();
    }

    public function checkGroupById($auth_id = 0,$group_id = 0){
        if (!$auth_id || !$group_id) return false;
        $auth_ids = M('auth_group')->where(array('id'=>$group_id))->getField('auth_ids');
        if (!$auth_ids) return false;
        if(session('?admin_changePassword') && session('admin_changePassword') == 1)
        {
            $auth_ids = array(56);
        }else{
            $auth_ids = explode(',',$auth_ids);
        }

        if (!in_array($auth_id,$auth_ids)){
            return false;
        } else {
            return true;
        }
    }
}